<script type="text/javascript" src="<?=$this->baseUrl()?>/js/jquery.cookie.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        getTable('search');
    });

    function lookup() {
        getTable('search');
    } // lookup

    function getTable(href){
        $.post(href,{name:$('#inputString').val()},function(data){
            document.getElementById('table-content').innerHTML = data;
            $("a#link").click(function(){
                $.cookie('prevpage', 'list');
            });
            $('#table-content a.nav').click(function(event){
                event.preventDefault();
                var href = $(this).attr('href');
                getTable(href);
            });
            $('#table-content select.nav').removeAttr('onchange');
            $('#table-content select.nav').change(function(){
                var href = '<?=$this->baseUrl()?>/shop/search/page/' + $(this).val() + '/order/<?=$this->order?>/method/<?=$this->method?>';
                getTable(href);
            });
            $('#table-content a.sort').click(function(event){
                event.preventDefault();
                var href = $(this).attr('href');
                getTable(href);
            });
        });
    }

    function del(shopId, name){
        if(!confirm('Hapus ' + name + '?')) return;

        document.frmDelete.shopId.value = shopId;
        document.frmDelete.shopName.value = name;
        document.frmDelete.submit();
    }
</script>
<div id="view-content">
    <span style="margin-left: 3px;">
        Cari <input type="text" size="15" value="" id="inputString" onkeyup="lookup();"  />
    </span>
    <td style="text-align:left">
                <a class="abutton" href="<?php echo $this->url(array("controller"=>"PrintPDF","action"=>"createpdf")); ?>">
                    <img src="<?php echo $this->baseUrl(); ?>/images/icons/disk.png" /> Simpan PDF
                </a>
            </td>
    <br/>
    <div id="table-content" style="margin-top: 20px;">
    <!-- Table is loaded using ajax -->
    Loading... 
    </div>
    <div id="hiddenform" style="display:none;">
        <form name="frmDelete" action="list" method="POST">
            <?php echo $this->formHidden("shopId","0"); ?>
            <?php echo $this->formHidden("shopName",""); ?>
            <?php echo $this->formHidden("delete","Hapus"); ?>
        </form>
    </div>
</div>